package blog.controller;

import blog.entity.Thumb;
import blog.service.client.ThumbClientService;
import blog.vo.client.BlogVO;
import blog.vo.client.ThumbCountVO;
import blog.vo.client.ThumbVO;
import blog.vo.common.ResponseListObjectVO;
import blog.vo.common.ResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 　　* @description: TODO
 * 　　* @param
 * 　　* @return
 * 　　* @throws
 * 　　* @author Administrator
 * 　　* @date $ $
 *
 */
@RestController
@RequestMapping("/thumb")
public class ThumbController {
    @Autowired
    private ThumbClientService thumbClientService;

    @PostMapping("/thumb-count")
    public ResponseVO<Integer> thumbCount(@RequestBody ThumbCountVO thumbVO){
        Integer thumbCount = thumbClientService.thumbCount(thumbVO);
        return new ResponseVO<Integer>(200,"ok",thumbCount);
    }

    @PostMapping("/add-thumb")
    public ResponseVO<Integer> addThumb(@RequestBody ThumbVO thumbVO){
        int result = thumbClientService.addThumb(thumbVO);
        if (result > 0){
            return new ResponseVO<Integer>(200,"ok",result);
        }
        else {
            return new ResponseVO<Integer>(200,"ok",result);
        }
    }

    @PostMapping("/is-add-thumb")
    public ResponseVO<Integer> isAddThumb(@RequestBody ThumbVO thumbVO){
        int result = thumbClientService.isAddThumb(thumbVO);
        if (result == 0){
            return new ResponseVO<Integer>(200,"ok",0);
        }
        else {
            return new ResponseVO<Integer>(200,"ok",1);
        }
    }

    @PostMapping("/cancel-add-thumb")
    public ResponseVO<Integer> cancelAddThumb(@RequestBody ThumbVO thumbVO){
        int result = thumbClientService.cancelAddThumb(thumbVO);
        if (result > 0){
            return new ResponseVO<Integer>(200,"ok",result);
        }
        else {
            return new ResponseVO<Integer>(200,"ok",result);
        }
    }
}
